<HTML>

<HEAD>
<TITLE>XsMotifWindow Class</TITLE>
<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>

<H2>
The XsMotifWindow Class
</H2>

<P>
The <I>XsMDICanvas</I> requires that all documents be a subclass of 
<I>XsMDIWindow</I> or a subclass of a class derived from it.  By itself
<I>XsMDIWindow</I> does not define any appearance or behavior for the
documents.  However, <I>XsMotifWindow</I>, derived from <I>XsMDIWindow</I>,
defines a MWM-like look-and-feel to a document.

<P>
Documents in your application should be derived from <I>XsMotifWindow</I>.  
This class provides the look-and-feel of Motif window and supports the 
interaction with the <I>XsMDICanvas</I>.  It is up to the application to 
define the contents of each document.

<P>
<B>Constructor and Destructor:</B>

<P>
The <I>XsMotifWindow</I> constructor accepts one argument:

<DL>
<DD>XsMotifWindow (const char *name)</DD>
</DL>

<P>
The <I>name</I> parameter specifies the name of the document and is used
as the widget name for the underlying implementation.  The name parameter
is also used as the default title and icon-name for the document.  

<P>
<B>Note:</B>  The <I>XsMotifWindow</I> constructor does not create any
widgets.  Rather it only initializes internal variables.  The widgets are
not created until the document is added to the canvas.  The <I>XsMDICanvas</I>
calls the member-function <I>XsMotifWindow::_buildClientArea()</I> when it needs
to create the document widgets.

<P>
The <I>XsMotifWindow</I> destructor destroys the document widgets (if they have
been created) and frees its internal storage.  It is up to the application
to free all documents.  The <I>XsMDICanvas</I> will <B>not</B> destroy the
documents for you.

<P>
<B>Document Utilities:</B>

<P>
Although rarely called from the application, the <I>XsMotifWindow</I> supports
a number of utility functions to manipulate the document.

<DL>
<DD>virtual void raise ( )</DD>
<DD>virtual void lower ( )</DD>
<DD>virtual void minimize ( )</DD>
<DD>virtual void maximize ( )</DD>
<DD>virtual void restore ( )</DD>
<DD>virtual void close ( )</DD>
</DL>

<P>
The <I>close</I> member-function does not destroy the document, it simply
hides it from view.  You can restore a closed document with
<I>XsMotifWindow::show()</I>.

<P>
The following member-functions are used to change/query the appearance of
the document:

<DL>
<DD>void  setTitle (const char *name)</DD>
<DD>const char *title ( ) const</DD>
<DD>void  setIconName (const char *name)</DD>
<DD>const char *iconName ( ) const</DD>
<DD>void  setPixmap (Pixmap pixmap)</DD>
<DD>Pixmap pixmap ( ) const</DD>
<DD>Widget icon ( ) const</DD>
<DD>Boolean minimized ( ) const</DD>
<DD>Boolean  maximized ( ) const</DD>
<DD>virtual void setPosition (Position x, Position y)</DD>
<DD>virtual void setSize (Dimension width, Dimension height)</DD>
</DL>

<P>
The <I>setPixmap</I> member-function accepts a pixmap which the document then
uses as the decoration on the icon.  Because the document does not make a copy 
of the pixmap, it is important that the application not free the pixmap until 
all documents that reference it are deleted.  The document does, however, make 
a local copy of the title or icon-name string passed to it, so the application
is free to do whatever it wants to the passed-in string.  The <I>icon</I>
member-function returns the widget that is used to implement the icon.


<P>
<B>Creating Window Subclasses:</B>

<P>
The application must derive its documents from <I>XsMotifWindow</I> in order to
define the contents of the document.  The <I>XsMDICanvas</I> calls the
protected member-function <I>_buildClientArea</I> when it creates the 
document. Each class derived from <I>XsMotifWindow</I> <B>must</B> override
this pure-virtual member-function.

<P>
The member-function <I>_buildClientArea</I> is called with a single argument:

<DL>
<DD>virtual void _buildClientArea (Widget parent)</DD>
</DL>

The <I>parent</I> argument should be used as the parent of the contents of
the document.  This widget is an unmanaged <I>XmForm</I> widget, and all of 
the standard resources and constrains apply to it.  The <I>XsMDICanvas</I>
is responsible for managing the parent widget at the appropriate time.

<P>
As an example, consider the following:

<PRE>
// _buildClientArea (called to create document contents)

void MyDocument::_buildClientArea (Widget parent)
{
   assert (parent != 0);
   
// Create a main window with some dummy menus

   Widget mainW = XtVaCreateWidget ("mainWin", xmMainWindowWidgetClass, parent,
      XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
      XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
      NULL);
   ...
   
   XtManageChild (mainW);
}
</PRE>

<P>
In this case, an <I>XmMainWindow</I> is created as the child of the parent
widget.  The <I>XmMainWindow</I> is then attached to the 4 sides of the parent
form.  Note also that the main window is managed before returning from the
function.

<P>
<B>Resources:</B>

<P>
The <I>XsMotifWindow</I> supports the following resources:

<PRE>
   Name              Class             Type           Default
------------------------------------------------------------------------------
   borderSize        BorderSize        Dimension      6
   buttonSize        ButtonSize        Dimension      23
   title             Title             String         dynamic
   titleFont         TitleFont         String         -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-iso8859-1
   iconSize          IconSize          Dimension      70
   iconName          IconName          String         dynamic
   iconFont          IconFont          String         *-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-1
   XmNiconX          XmCIconX          Position       dynamic
   XmNiconY          XmCIconY          Position       dynamic
   saveUnder         SaveUnder         Boolean        True
   restoreString     RestoreString     String         "Restore"
   moveString        MoveString        String         "Move"
   sizeString        SizeString        String         "Size"
   minimizeString    MinimizeString    String         "Minimize"
   maximizeString    MaximizeString    String         "Maximize"
   raiseString       RaiseString       String         "Raise"
   lowerString       LowerString       String         "Lower"
   closeString       CloseString       String         "Close"
   menuFont          MenuFont          String         -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-iso8859-1
   showBorder        ShowBorder        Boolean        True
   showResize        ShowResize        Boolean        True
   showTitle         ShowTitle         Boolean        True
   showMenu          ShowMenu          Boolean        True
   showMinimize      ShowMinimize      Boolean        True   
   showMaximize      ShowMaximize      Boolean        True
   lowerOnIconify    LowerOnIconify    Boolean        False
   XmNminWidth       XmCMinWidth       Dimension      dynamic
   XmNmaxWidth       XmCMaxWidth       Dimension      dynamic
   XmNminHeight      XmCMinHeight      Dimension      dynamic
   XmNmaxHeight      XmCMaxHeight      Dimension      dynamic
</PRE>

<DL>
<DD>
<DL>
<DT>borderSize</DT>
<DD>Size of the window border.</DD>
<DT>buttonSize</DT>
<DD>Size of the window buttons.</DD>
<DT>title</DT>
<DD>Title of the window.  The default is the name of the window instance.</DD>
<DT>titleFont</DT>
<DD>Font used to draw the window title.</DD>
<DT>iconSize</DT>
<DD>Size of the icon representation.</DD>
<DT>iconName</DT>
<DD>String used on the title.  If unspecified, the window title is used.</DD>
<DT>iconFont</DT>
<DD>Font used to draw the icon-name.</DD>
<DT>XmNiconX</DT>
<DD>X-position of the icon.  The default location is the top-left
corner of the window when it is iconified.</DD>
<DT>XmNiconY</DT>
<DD>Y-position of the icon.  The default location is the top-left
corner of the window when it is iconified.</DD>
<DT>saveUnder</DT>
<DD>Enables/Disables save-unders for the menu.</DD>
<DT>restoreString</DT>
<DD>String used as the "restore" menu item.</DD>
<DT>moveString</DT>
<DD>String used as the "move" menu item.</DD>
<DT>sizeString</DT>
<DD>String used as the "size" menu item.</DD>
<DT>minimizeString</DT>
<DD>String used as the "minimize" menu item.</DD>
<DT>maximizeString</DT>
<DD>String used as the "maximize" menu item.</DD>
<DT>raiseString</DT>
<DD>String used as the "raise" menu item.</DD>
<DT>lowerString</DT>
<DD>String used as the "lower" menu item.</DD>
<DT>closeString</DT>
<DD>String used as the "close" menu item.</DD>
<DT>menuFont</DT>
<DD>Font used to draw the menu strings.</DD>
<DT>showBorder</DT>
<DD>Enables/Disables the window border.  If the border is disabled,
the resize-handles are automatically disabled.</DD>
<DT>showResize</DT>
<DD>Enables/Disables the window resize handles.</DD>
<DT>showTitle</DT>
<DD>Enables/Disables the window title.  If the title is disabled,
all of the window buttons are automatically disabled.</DD>
<DT>showMenu</DT>
<DD>Enables/Disables the window menu button.</DD>
<DT>showMinimize</DT>
<DD>Enables/Disables the window minimize button.</DD>
<DT>showMaximize</DT>
<DD>Enables/Disables the window maximize button.</DD>
<DT>lowerOnIconify</DT>
<DD>Automatically lower windows when iconified.</DD>
<DT>XmNminWidth</DT>
<DD>Minimium window width.  The default is about four times the size of
the window button.</DD>
<DT>XmNmaxWidth</DT>
<DD>Maximum window width.  The default is not to constrain the maximum size.</DD>
<DT>XmNminHeight</DT>
<DD>Minimum window height.  The default is about four times the size of
the window button.</DD>
<DT>XmNmaxHeight</DT>
<DD>Maximum window height.  The default is not to constrain the maximum size.</DD>
</DL>
</DD>
</DL>

<P>
<B>XsMotifWindow Implementation:</B>

<P>
As a convenience to those who wish to modify the <I>XsMotifWindow</I> code,
here is a diagram of the internal class structure:

<P>
<IMG SRC="pics/winclass.gif" ALT="[Class Structure]">

</BODY>
</HTML>
